#ifndef STANDARDITEMMODEL_H
#define STANDARDITEMMODEL_H

#include <QAbstractTableModel>
#include <QStandardItemModel>
#include <QFile>
#include <QTextStream>
#include <QVariant>




class StandardItemModel : public QStandardItemModel
{
    Q_OBJECT

public:
    explicit StandardItemModel(QObject *parent = nullptr);
    Q_INVOKABLE void importData();
    Q_INVOKABLE QHash<int,QVariantList> getModel();
    Q_INVOKABLE QHash<int,QVariantList> modelToHash(QStandardItemModel *model);

protected:
    // Header:
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    // Basic functionality:
    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const override;
    //QModelIndex parent(const QModelIndex &index) const override;

    //get col count
    int rowCount(const QModelIndex & = QModelIndex()) const override
    {
        return hash.count();
    }

    //get row count
    int columnCount(const QModelIndex & = QModelIndex()) const override
    {
        return m_header.count();
    }

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

private:
    QVariantList m_header;
    QHash<int,QVariantList> hash;
    void iniModelFromStringList(QStringList &aFileContent);
};

#endif // STANDARDITEMMODEL_H
